Ext.define('component.proceeds.internalTransferWin', {
	extend : 'Ext.window.Window',
	callbackFun: function (record) {
		Ext.Msg.alert('提示', '回调函数未配置！');
	},
	initComponent : function() {
		var me = this;
		var gridStore = Ext.create('Ext.data.Store', {
		    fields:[
		    	'businessCode', 'customerName', 'roomName','moneyType','happendAmount',
				'canTraAmount','billCode','settleDate','settleMember','settleMode'
			],
		    pageSize: 10,  //页容量5条数据
		    //是否在服务端排序 （true的话，在客户端就不能排序）
		    remoteSort: false,
		    proxy: {
		        type: 'ajax',
		        url: jypath+'/customer/customer/customerComponentList',
		        reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
		            type: 'json', //返回数据类型为json格式
		            root: 'rows',  //数据
		            totalProperty: 'total' //数据总条数
		        },
		        actionMethods: {read: 'POST'}
		        
		    },
		    autoLoad: true  //即时加载数据
		});
		//房款类型
		var houseFundType = [
			{"value":"1","text":"大定金"}
     	];
		var houseFundTypeStore = Ext.data.Store({
	    	autoDestroy: true,
	        fields :["value","text"],
	        data : houseFundType
	    });
	    
	    //房款类型
		var businessType = [
			{"value":"1","text":"业务类型待定"}
     	];
		var businessTypeStore = Ext.data.Store({
	    	autoDestroy: true,
	        fields :["value","text"],
	        data : businessType
	    });
		
		var columns = [
			{ text: '业务编号',  dataIndex: 'businessCode' },
	        { text: '客户名称', dataIndex: 'customerName' },
	        { text: '房号', dataIndex: 'roomName' },
	        { text: '房款类型', dataIndex: 'moneyType' },
	        { text: '业务标志', dataIndex: 'businessType' },
	        { text: '发生额', dataIndex: 'happendAmount' },
	        { text: '可转金额', dataIndex: 'canTraAmount' },
	        { text: '票据号码', dataIndex: 'piaoju' },
	        { text: '结算日期', dataIndex: 'settleDate' },
	        { text: '结算人员', dataIndex: 'settleMember' },
	        { text: '结算方式', dataIndex: 'settleMode'}
		];
		
		var bbar=Ext.create('Ext.PagingToolbar', {
			store : gridStore,
			displayInfo : true
		})
		var grid=Ext.create('Ext.grid.Panel', {
			minHeight:400,
			store : gridStore,
			columns : columns,
			bbar : bbar,
			selModel:  Ext.create('Ext.selection.CheckboxModel', {
				checkOnly:true
			})
		});

		var form = Ext.create("Ext.form.Panel", {
		    minHeight:60,
		    collapsible: true,  //可折叠
		    autoScroll: false,   //自动创建滚动条
		    defaultType: 'textfield',
		    fieldDefaults: {
		        flex: 1,
		        margin: 2
		    },
		    items: [{
		            xtype: "container",
		            layout: "hbox",
		            width: 300,
		            items: [{
			            xtype: 'fieldcontainer',
			            fieldLabel: '业务类型',
			            defaultType: 'checkboxfield',
			            layout: "hbox",
			            items: [{
			                    boxLabel: '认筹',
			                    name: 'deposit',
			                    inputValue: '1',
			                    id: 'deposit'
			                }, {
			                    boxLabel: '认购',
			                    name: 'subscribe',
			                    inputValue: '2',
			                    id: 'subscribe'
			                }, {
			                    boxLabel: '签约',
			                    name: 'signed',
			                    inputValue: '3',
			                    id: 'signed'
			                }
			            ]}
		            ]
		        },{
		        	xtype: "container",
		        	layout: "hbox",
		        	width: 600,
		        	items: [{
	                	xtype: "textfield",
	                	name: "customerName",
	                	fieldLabel: "客户名称",
	                	width: 60
	            	},{
	                	xtype: "textfield",
	                	name: "agent",
	                	fieldLabel: "置业顾问",
	                	width: 60
	            	}]
		        },{
		        	xtype: "container",
		            layout: "hbox",
		            width: 600,
		        	items: [{
			      		xtype : 'combobox',
						fieldLabel : '房款类型',
						store: houseFundTypeStore,
				    	displayField: "text",
				    	valueField:"value"
			        },{
			      		xtype : 'combobox',
						fieldLabel : '业务标志',
						store: businessTypeStore,
				    	displayField: "text",
				    	valueField:"value"
			        }]
		        },{
		        	xtype: "container",
		        	layout: {type: 'hbox', align: 'middle', pack: 'center'},
		        	padding: "10 0 0 0",
		        	width: 600,
		        	items: [{
	        			xtype: "button", text: "查询", iconCls:'icon-search', textAlign: "center",
	        			handler: function(){
							alert("查询已收认筹、认购、签约记录!");	        			
	        			}
	        		},{
	        			xtype: "button",text: "确认选择", margin: "0 0 0 10",
            			iconCls:'icon-add', textAlign: "left",
            			handler:function(){
			            	var record = grid.getSelectionModel().getLastSelected();
			            	if(null==record){
			            		Ext.Msg.alert('提示', '请选择一个客户！');
			            		return;
			            	}
			            	var jsonRecord=Ext.JSON.encode(record.data);
			            	me.callbackFun(jsonRecord);
			            	me.close();
            			}
        			}]
		        }]
		});

		var mainPanel=Ext.create('Ext.panel.Panel', {
		    items:[form,grid]
		});
		
		var defaultConfig = {
				frame:true,
				title : '内部转账',
				width : 760,
				height : 500,
				layout : 'fit',
				items:[mainPanel]
		};
		Ext.apply(this,defaultConfig);
		this.callParent();
	}
});
